package com.woniuxy.ticketmovie.controller;



import com.woniuxy.ticketmovie.entity.ResponceResult;
import com.woniuxy.ticketmovie.entity.dto.MovieDTO;
import com.woniuxy.ticketmovie.service.Ticket_movieService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author movie
 * @since 2021-02-21
 */
@RestController
@RequestMapping("/ticket_movie")
@Slf4j
public class Ticket_movieController {

    @Autowired
    private Ticket_movieService ticketMovieService;

    @PostMapping("addMovie")
    public ResponceResult<Void> addMovie(@RequestBody MovieDTO movieDTO){

        log.debug(movieDTO.getMovie().getName()+movieDTO.getMovie().getActor());

        for (int typeId : movieDTO.getTypeIds()) {
            log.debug(String.valueOf(typeId));
        }
        ticketMovieService.add(movieDTO.getMovie(),movieDTO.getTypeIds());
        return ResponceResult.SUCCESS;
    }

    @GetMapping("deleteMovie")
    public ResponceResult<Void> deleteMovie(Integer id){

        ticketMovieService.delete(id);

        return ResponceResult.SUCCESS;
    }

}

